<template>
  <div class="college">
    <div class="newItem">
      <div class="itemTitle">学生比例数据</div>
      <div class="dataIntro">{{ majorData.proportion_text }}</div>
    </div>
    <div class="proportionView">
      <div class="viewItem">
        <div class="viewTitle">男女比例</div>
        <div style="position: relative;">
          <div id="echart1" style="width: 2.51rem; height: 2.43rem;"></div>
          <div style="width: 2.51rem; height: 2.43rem; position: absolute; top: 0; left: 0; z-index: 10;"></div>
        </div>
        <div class="dataShowList">
          <div class="dataItem">
            <div class="women circle"></div>
            <div class="data">女：{{ (majorData.proportion_gender_female ? majorData.proportion_gender_female : 0) + '%' }} </div>
          </div>
          <div class="dataItem">
            <div class="man circle"></div>
            <div class="data">男：{{ (majorData.proportion_gender ? majorData.proportion_gender : 0) + '%' }} </div>
          </div>
        </div>
      </div>
      <div class="viewItem">
        <div class="viewTitle">高考文理比例</div>
        <div style="position: relative;">
          <div id="echart2" style="width: 2.51rem; height: 2.43rem;"></div>
          <div style="width: 2.51rem; height: 2.43rem; position: absolute; top: 0; left: 0; z-index: 10;"></div>
        </div>
        <div class="dataShowList">
          <div class="dataItem">
            <div class="science circle"></div>
            <div class="data">理：{{ (majorData.proportion_wenli_li ? majorData.proportion_wenli_li : 0) + '%' }} </div>
          </div>
          <div class="dataItem">
            <div class="arts circle"></div>
            <div class="data">文：{{ (majorData.proportion_wenli ? majorData.proportion_wenli : 0) + '%' }} </div>
          </div>
        </div>
      </div>
    </div>
    <!-- <div class="searchBtn">历年录取分数线查询</div> -->
    <div class="line" v-show="majorData.xkyq"></div>
    <div class="xkyq" v-show="majorData.xkyq">
      <div class="title">专业限科要求</div>
      <div class="content">{{ majorData.xkyq ? majorData.xkyq : '' }}</div>
    </div>
  </div>
</template>

<script>
// import echarts from "@/plugins/echarts";
// import echarts from 'echarts'
export default {
  name: "College",
  props: {
    majorData: Object
  },
  mounted() {
    this.drawSexCircle()
    this.drawCollegeCircle()
  },
  methods: {
    drawSexCircle() {
      var chart1 = echarts.init(document.getElementById("echart1"));
      var option1 = {
        tooltip: {
          show: false,
          trigger: "item",
          // formatter: "{a} <br/>{b}: {c} ({d}%)"
        },
        legend: {
          orient: "vertical",
          x: "left",
          data: ['1', '2']
        },
        series: [
          {
            name: "男女比例",
            type: "pie",
            radius: ["50%", "100%"],
            color:['#5B8FF9', '#5AD8A6'],
            avoidLabelOverlap: false,
            label: {
              normal: {
                show: false,
                position: "center"
              },
              emphasis: {
                show: true,
                textStyle: {
                  fontSize: "30",
                  fontWeight: "bold"
                }
              }
            },
            labelLine: {
              normal: {
                show: false
              }
            },
            data: [
              { value: (100 - this.majorData.proportion_gender), name: "女" },
              { value: this.majorData.proportion_gender, name: "男" }
            ]
          }
        ]
      };
      chart1.setOption(option1);
    },
    drawCollegeCircle() {
      var chart2 = echarts.init(document.getElementById("echart2"));
      var option2 = {
        tooltip: {
          show: false,
          trigger: "item",
          // formatter: "{a} <br/>{b}: {c} ({d}%)"
        },
        legend: {
          orient: "vertical",
          x: "left",
          data: ['1', '2']
        },
        series: [
          {
            name: "高考文理比例",
            type: "pie",
            radius: ["50%", "100%"],
            color:['#F7C739', '#A786E0'],
            avoidLabelOverlap: false,
            label: {
              normal: {
                show: false,
                position: "center"
              },
              emphasis: {
                show: true,
                textStyle: {
                  fontSize: "30",
                  fontWeight: "bold"
                }
              }
            },
            labelLine: {
              normal: {
                show: false
              }
            },
            data: [
              { value: (100 - this.majorData.proportion_wenli), name: "理" },
              { value: this.majorData.proportion_wenli, name: "文" }
            ]
          }
        ]
      };
      chart2.setOption(option2);
    }
  }
};
</script>

<style lang="less" scoped>
.college {
  .newItem {
    margin-bottom: 0.32rem;
    .itemTitle {
      color: #222;
      font-size: 0.3rem;
      font-weight: bold;
      line-height: 0.44rem;
      margin-bottom: 0.4rem;
    }
    .dataIntro {
      color: #222;
      font-size: 0.28rem;
      line-height: 0.4rem;
    }
    .echart {
      width: 2.51rem;
      height: 2.43rem;
    }
  }
  .proportionView {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    .viewItem {
      text-align: center;
      .viewTitle {
        color: #000;
        font-size: 0.28rem;
        font-weight: bold;
        line-height: 0.4rem;
        margin-bottom: 0.62rem;
      }
      .dataShowList {
        display: flex;
        justify-content: flex-start;
        align-items: center;
        margin-top: 0.3rem;
        .dataItem {
          display: flex;
          justify-content: flex-start;
          align-items: center;
          margin-right: 0.16rem;
          .circle {
            width: 0.2rem;
            height: 0.2rem;
            border-radius: 50%;
            margin-right: 0.16rem;
          }
          .women { background: #5B8FF9; }
          .man { background: #73DEB3; }
          .science { background: #F7C739; }
          .arts { background: #A786E0; }
          .data {
            color: #8C8C8C;
            font-size: 0.2rem;
            line-height: 0.28rem;

          }
        }
      }
    }
  }
  .searchBtn {
    width: 100%;
    height: 0.96rem;
    line-height: 0.96rem;
    text-align: center;
    border-radius: 0.48rem;
    background: #F7F7FA;
    color: #999;
    font-size: 0.28rem;
    font-weight: bold;
  }
  .line {
    width: 100%;
    height: 0.02rem;
    background: #E5E8ED;
    margin-bottom: 0.48rem;
  }
  .xkyq {
    .title {
      color: #222;
      font-size: 0.3rem;
      font-weight: bold;
      line-height: 0.4rem;
      margin-bottom: 0.4rem;
    }
    .content {
      color: #222;
      font-size: 0.28rem;
      line-height: 0.4rem;
    }
  }
}
</style>
